#include <boost/test/unit_test.hpp>

#include <boost/mpl/lambda.hpp>

#include <phalanx/utility/apply_if.hpp.cu>

#include <phalanx/type_traits/integral_constant.hpp.cu>
#include <phalanx/type_traits/add_const.hpp.cu>
#include <phalanx/type_traits/add_volatile.hpp.cu>
#include <phalanx/type_traits/is_same.hpp.cu>
using namespace phalanx;

typedef add_const< ::boost::mpl::_1 > add_const_;

namespace ns_apply_if
{

BOOST_AUTO_TEST_CASE( check )
{
    BOOST_REQUIRE(( is_same<
      apply_if_c< false, add_const_, int >::type,
      int >::value ));

    BOOST_REQUIRE(( is_same<
      apply_if_c< true, add_const_, int >::type,
      const int >::value ));

    BOOST_REQUIRE(( is_same<
      phalanx::apply_if< false_type, add_const_, int >::type,
      int >::value ));

    BOOST_REQUIRE(( is_same<
      phalanx::apply_if< true_type, add_const_, int >::type,
      const int >::value ));
}

BOOST_AUTO_TEST_CASE( lazy_check )
{
    BOOST_REQUIRE(( is_same<
      lazy_apply_if_c< false, add_const_, add_volatile< int > >::type,
      volatile int >::value ));

    BOOST_REQUIRE(( is_same<
      lazy_apply_if_c< true, add_const_, add_volatile< int > >::type,
      const volatile int >::value ));

    BOOST_REQUIRE(( is_same<
      lazy_apply_if< false_type, add_const_, add_volatile< int > >::type,
      volatile int >::value ));

    BOOST_REQUIRE(( is_same<
      lazy_apply_if< true_type, add_const_, add_volatile< int > >::type,
      const volatile int >::value ));
}

} // namespace ns_apply_if

